<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of content_change
 *
 * @author phamtruong
 */
class content_change extends CI_Controller {

    //asdasds
    public function index() {
        $id_article = 21;
        $id_used = 3;
        if (is_int($id_article) == FALSE)
            $data['thong_bao'] = "bai viet chua duoc khai sinh =.=!";
        else {
            if ($id_used == null)
            //go to login page
                $data['thong_bao'] = "DUA TIEN DAY TA CHO VAO! >" . '"<';

            else {
                $this->load->model("content_change_model");
                $data['article'] = $this->content_change_model->get_titel($id_article);
                $data['content'] = $this->content_change_model->get_content($id_article);
                $page['content'] = $this->load->view("page/content/change", $data, true);
                $this->load->view("layout", $page);
            }
        }
    }

    public function update() {
        $id_article = 21;
        $id_used = 3;
        if (is_int($id_article) == FALSE) {
            echo "bai viet chua duoc khai sinh =.=!";
            return;
        } else {
            if ($id_used == null)
            //go to login page
                echo "DUA TIEN DAY TA CHO VAO! >" . '"<';
            else {
                $this->load->model("content_change_model");
                $this->content_change_model->update_article($id_article, $id_used);
                $data['article'] = $this->content_change_model->get_titel($id_article);
                $data['content'] = $this->content_change_model->get_content($id_article);
//        $this->content_change_model->get_version($id_article);
                $data['thong_bao'] = 'Bài viết của bạn đã được chỉnh sửa!';
                $page['content'] = $this->load->view("page/content/change", $data, true);
                $this->load->view("layout", $page);
            }
        }
    }

}

?>
